import {previewShowApi} from '../rule/const';
export default function getPreviewObj() {
    const previewObj = reactive(
        {
            visible: false,
            data: [],
            courseParentName: '',
            courseBankTypeName: '',
            preview: (row) => {
                // previewShowApi
                previewObj.courseParentName = row.courseParentName
                previewObj.courseBankTypeName = row.courseBankTypeName
                previewShowApi({
                  "ruleId": row.id || null,
                  "typeCode": "practise"
                }).then((res) => {
                  previewObj.data = res.rows || []
                  previewObj.data.map((item) => {
                    if (item.typeAmountConf) {
                      item.typeAmountConf.single ? '' : item.typeAmountConf.single = 0
                      item.typeAmountConf.multiple ? '' : item.typeAmountConf.multiple = 0
                      item.typeAmountConf.judge ? '' : item.typeAmountConf.judge = 0
                      item.typeAmountConf.case ? '' : item.typeAmountConf.case = 0
                      item.caseGroupSize ? '' : item.caseGroupSize = 0
                      item.totalAmountQuestion = item.typeAmountConf.fillBlank +item.typeAmountConf.shortAnswer +item.typeAmountConf.single + item.typeAmountConf.multiple + item.typeAmountConf.judge + (item.typeAmountConf.case * item.caseGroupSize)
                    }
                  })
                  previewObj.visible = true
                })
            }
        }
    )
    return previewObj;
  }